<script setup>
import { useI18n } from 'vue-i18n'
import { ref, onMounted } from 'vue'

const { t } = useI18n()
const isVisible = ref(false)
const guideLeftRef = ref(null)
const circleSmallRef = ref(null)
const circleLargeRef = ref(null)
const dotPatternLeftRef = ref(null)
const dotPatternRightRef = ref(null)

onMounted(() => {
  const observer = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
      if (entry.isIntersecting) {
        isVisible.value = true
        observer.disconnect()
      }
    })
  }, { threshold: 0.2 })
  
  if (guideLeftRef.value) {
    observer.observe(guideLeftRef.value)
  }
})
</script>

<template>
  <section class="payment-guide-section">
    <div class="payment-guide-container">
      <div 
        ref="guideLeftRef" 
        class="guide-left" 
        :class="{ 'animate': isVisible }"
      >
        <div class="compass-icon animate-bounce">
          <img src="@/assets/icons/compass.png" alt="compass icon" class="compass-img">
        </div>
        
        <div class="payment-text">
          <span class="subtitle-green">About payment</span>
          <h2 class="guide-title">如何实现轻松支付</h2>
          <p class="guide-description">
            苹果支付，移动支付为首选，将微信或支付宝绑定银行卡可便捷消费。银联卡、国际信用卡、现金支付各有用武之地，结合使用更轻松。
          </p>
          
          <ul class="features-list">
            <li class="animate-item"><span class="check-icon">✓</span> Luctus risusd diam eget</li>
            <li class="animate-item"><span class="check-icon">✓</span> Donec enim congue magna</li>
            <li class="animate-item"><span class="check-icon">✓</span> Blandit sit amet non magna</li>
          </ul>
        </div>
      </div>
    </div>
    
    <div ref="circleLargeRef" class="circle-large" :class="{ 'animate': isVisible }"></div>
    <div ref="circleSmallRef" class="circle-small" :class="{ 'animate': isVisible }"></div>
    <div ref="dotPatternLeftRef" class="dot-pattern left" :class="{ 'animate': isVisible }"></div>
    <div ref="dotPatternRightRef" class="dot-pattern right" :class="{ 'animate': isVisible }"></div>
  </section>
</template>

<style scoped>
.payment-guide-section {
  height: 938px;
  padding: 0;
  background-color: #FFFFFF;
  background-image: url('@/assets/PG-bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.payment-guide-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.payment-guide-container {
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  position: relative;
  z-index: 2;
}

.guide-left {
  margin-left: 152px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  max-width: 650px;
  opacity: 0;
  transform: translateX(-50px);
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.guide-left.animate {
  opacity: 1;
  transform: translateX(0);
}

.compass-icon {
  margin-bottom: 20px;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.animate-bounce {
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.compass-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.payment-text {
  display: flex;
  flex-direction: column;
}

.subtitle-red {
  font-size: 1.75rem;
  color: #FD4C5C;
  font-weight: 600;
  margin-bottom: 4px;
}

.subtitle-green {
  font-size: 1.25rem;
  color: #00C389;
  font-weight: 500;
  margin-bottom: 16px;
}

.guide-title {
  font-size: 2.5rem;
  color: #2A2D32;
  font-weight: 700;
  margin-bottom: 20px;
}

.guide-description {
  font-size: 1.1rem;
  color: #52565E;
  line-height: 1.7;
  margin-bottom: 30px;
  max-width: 550px;
}

.features-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.features-list li {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  font-size: 1.1rem;
  color: #52565E;
}

.animate-item {
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.5s ease;
}

.guide-left.animate .animate-item:nth-child(1) {
  opacity: 1;
  transform: translateX(0);
  transition-delay: 0.3s;
}

.guide-left.animate .animate-item:nth-child(2) {
  opacity: 1;
  transform: translateX(0);
  transition-delay: 0.5s;
}

.guide-left.animate .animate-item:nth-child(3) {
  opacity: 1;
  transform: translateX(0);
  transition-delay: 0.7s;
}

.check-icon {
  color: #00C389;
  font-weight: bold;
  margin-right: 10px;
  font-size: 1.2rem;
}

.guide-right {
  display: none;
}

.circle-large {
  width: 467px;
  height: 610px;
  border-radius: 305px;
  background-image: url('@/assets/home/explore3.jpg');
  background-size: cover;
  background-position: center;
  position: absolute;
  right: 140px;
  top: 116px;
  z-index: 2;
  border: 8px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: scale(0.8) translateX(50px);
  transition: all 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.circle-large.animate {
  opacity: 1;
  transform: scale(1) translateX(0);
}

.circle-small {
  width: 384px;
  height: 503px;
  border-radius: 252px;
  background-image: url('@/assets/home/explore4.jpg');
  background-size: cover;
  background-position: center;
  position: absolute;
  right: 395px;
  top: 315px;
  z-index: 3;
  border: 8px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: scale(0.8) translateX(50px);
  transition: all 1s cubic-bezier(0.16, 1, 0.3, 1) 0.2s;
}

.circle-small.animate {
  opacity: 1;
  transform: scale(1) translateX(0);
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

.dot-pattern {
  position: absolute;
  width: 80px;
  height: 360px;
  background-image: radial-gradient(#00C389 2px, transparent 2px);
  background-size: 12px 12px;
  z-index: 1;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.dot-pattern.animate {
  opacity: 1;
}

.dot-pattern.left {
  left: 0;
  top: 50px;
  transition-delay: 0.8s;
}

.dot-pattern.right {
  right: 0;
  bottom: 50px;
  transition-delay: 1s;
}

/* 响应式样式 */
@media (max-width: 1400px) {
  .guide-left {
    margin-left: 100px;
  }
  
  .guide-right {
    margin-right: 100px;
  }
  
  .circle-large {
    width: 400px;
    height: 520px;
    border-radius: 260px;
    right: 100px;
    top: 100px;
  }
  
  .circle-small {
    width: 340px;
    height: 450px;
    border-radius: 225px;
    right: 70px;
    top: 70px;
  }
}

@media (max-width: 1200px) {
  .payment-guide-container {
    flex-direction: column;
    align-items: center;
    padding: 0 40px;
  }
  
  .guide-left {
    margin-left: 0;
    margin-bottom: 60px;
    align-items: center;
    text-align: center;
  }
  
  .guide-right {
    margin-right: 0;
    width: 100%;
    justify-content: center;
  }

  .guide-description {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
  }
  
  .circle-large {
    right: 50%;
    transform: translateX(160px);
    width: 350px;
    height: 460px;
    border-radius: 230px;
    top: 80px;
  }
  
  .circle-large.animate {
    transform: translateX(160px);
  }
  
  .circle-small {
    right: 50%;
    transform: translateX(-100px);
    width: 300px;
    height: 400px;
    border-radius: 200px;
  }
  
  .circle-small.animate {
    transform: translateX(-100px);
    animation: float 6s ease-in-out infinite;
  }
  
  @keyframes float {
    0%, 100% {
      transform: translateX(-100px) translateY(0);
    }
    50% {
      transform: translateX(-100px) translateY(-15px);
    }
  }
}

@media (max-width: 768px) {
  .payment-guide-container {
    padding: 0 30px;
  }
  
  .guide-right {
    height: 300px;
  }
  
  .circle-large {
    width: 280px;
    height: 360px;
    border-radius: 180px;
    top: 50px;
  }
  
  .circle-small {
    width: 240px;
    height: 320px;
    border-radius: 160px;
    top: 50px;
  }
}

@media (max-width: 576px) {
  .payment-guide-container {
    padding: 0 20px;
  }
  
  .circle-small {
    width: 200px;
    height: 280px;
    border-radius: 140px;
  }
  
  .circle-large {
    width: 220px;
    height: 300px;
    border-radius: 150px;
  }
}
</style> 